package github.remonlong.restfulutil.exception;

import github.remonlong.restfulutil.exception.enumeration.EnumResult;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

/**
 * http请求返回的最外层对象
 * Created by remon
 * 2018-06-07 13:34
 */
@Data
@AllArgsConstructor
public final class Result<T> {


    /**
     * 错误码.
     */
    private Integer code;

    /**
     * 提示信息.
     */
    private String msg;

    /**
     * 具体的内容.
     */
    private T data;

    public Result() {
        this.code = EnumResult.BASE_SUCCESS.getCode();
        this.msg = EnumResult.BASE_SUCCESS.getMsg();
    }


    public Result(EnumResult result) {
        this.code = result.getCode();
        this.msg = result.getMsg();
    }

    public Result(T data) {
        this.code = EnumResult.BASE_SUCCESS.getCode();
        this.msg = EnumResult.BASE_SUCCESS.getMsg();
        this.data = data;
    }

}